package assets_withdraw

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserAuthUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 会员管理--实名认证--修改
func NewUserAuthUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAuthUpdateLogic {
	return &UserAuthUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserAuthUpdateLogic) UserAuthUpdate(req *types.UserAuthUpdateReq) (resp *types.UserAuthUpdateRes, err error) {
	rpc_req := &rpc.UserAuthUpdateReq{}
	rpc_req.Data = &rpc.UserAuth{}
	err = copier.Copy(&rpc_req.Data, req.UserAuth)
	// 发送请求
	rpc_resp, err := l.svcCtx.AssetsRpc.PayWithdraw.UserAuthUpdate(l.ctx, rpc_req)
	if err != nil {
		return nil, err
	}

	// 处理请求返回的结果
	// 解析、组合数据
	resp = &types.UserAuthUpdateRes{}
	err = copier.Copy(&resp.UserAuth, rpc_resp.Data)

	return
}
